package org.shj.hadoop.fs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.compress.GzipCodec;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider.Text;

public class Compress {

	public static void  main(String[] args) throws Exception{
		String inputPath = "";
		String outputPath = "";
		
		Configuration conf = new Configuration();
		Job job = new Job(conf);
		job.setJarByClass(Compress.class);
		FileInputFormat.addInputPath(job, new Path(inputPath));
		FileOutputFormat.setOutputPath(job, new Path(outputPath));
		
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(IntWritable.class);
		
		//压缩mapreduce的输出
		FileOutputFormat.setCompressOutput(job, true);
		FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class);
		
//		job.setMapperClass(cls);
//		job.setCombinerClass(cls);
//		job.setReducerClass(cls);
		
		System.exit(job.waitForCompletion(true) ? 0 : 1);
	}
}
